//
//  YCDJHomeViewController.m
//  YCDJHomePageDemo
//
//  Created by ASSASSIN on 10/10/2017.
//  Copyright © 2017 scbdh. All rights reserved.
//

#import "YCDJHomeViewController.h"
#import "YCDJSearchView.h"

@interface YCDJHomeViewController ()

@property(nonatomic,strong)YCDJSearchView *searchView;
@property(nonatomic,strong)UIBarButtonItem *shopcart;
@property(nonatomic,strong)UIBarButtonItem *favorite;
@property(nonatomic,strong)UIBarButtonItem *locate;

@end

@implementation YCDJHomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.leftBarButtonItem = self.locate;
    self.navigationItem.rightBarButtonItems = @[self.shopcart,self.favorite];
}

-(UIBarButtonItem *)shopcart{
    if (!_shopcart) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(gotoShopcart) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, 30, 30);
        [button setImage:[UIImage imageNamed:@"SHOPPING-CART"] forState:UIControlStateNormal];
        _shopcart = [[UIBarButtonItem alloc] initWithCustomView:button];
    }
    return _shopcart;
}

-(UIBarButtonItem *)favorite{
    if (!_favorite) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(gotoShopcart) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, 30, 30);
        [button setImage:[UIImage imageNamed:@"SHOPPING-CART"] forState:UIControlStateNormal];
        _favorite = [[UIBarButtonItem alloc] initWithCustomView:button];
    }
    return _favorite;
}

-(UIBarButtonItem *)locate{
    if (!_locate) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button addTarget:self action:@selector(gotoShopcart) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, 30, 30);
        [button setImage:[UIImage imageNamed:@"SHOPPING-CART"] forState:UIControlStateNormal];
        _locate = [[UIBarButtonItem alloc] initWithCustomView:button];
    }
    return _locate;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
